home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Demos / Simpsons Cartoon Studio™ Demo / Simpdata / simpmain / 00013_backgroundRecordManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-06  |  5.6 KB  |  160 lines

  1. property ancestor
  2. global baseRecordSprOffset, clipDataField, backgroundSpr, currentFrame, dispatchTable, bgdData, theStageBounds, curClipRecord, dirtyFlag
  3.  
  4. on birth me
  5.   set the ancestor of me to birth(script "recordMethods parent")
  6.   return me
  7. end
  8.  
  9. on record me
  10.   set slotNum to 1
  11.   set nukeSlots to []
  12.   set partsList to value(line 1 of field "partsListData")
  13.   repeat with theSlot in dispatchTable
  14.     if getAt(theSlot, 1) = "S" then
  15.       set searchString to getAt(theSlot, 2)
  16.       set found to 0
  17.       repeat with propNameList in partsList
  18.         repeat with propName in propNameList
  19.           if propName = searchString then
  20.             append(nukeSlots, slotNum)
  21.             set found to 1
  22.             exit repeat
  23.           end if
  24.         end repeat
  25.         if found then
  26.           exit repeat
  27.         end if
  28.       end repeat
  29.     end if
  30.     set slotNum to slotNum + 1
  31.   end repeat
  32.   if count(bgdData) < currentFrame then
  33.     set previousBackgroundCast to getLast(bgdData)
  34.   else
  35.     set previousBackgroundCast to getAt(bgdData, currentFrame)
  36.   end if
  37.   set backgroundCastNumber to getAt(curClipRecord, 4)
  38.   set the castNum of sprite backgroundSpr to backgroundCastNumber
  39.   cursor(-1)
  40.   set theMaxV to 316
  41.   set theMinV to 121
  42.   repeat while the mouseUp
  43.     set theMouseLoc to point(the mouseH, the mouseV)
  44.     if inside(theMouseLoc, theStageBounds) then
  45.       repeat with theSlot in nukeSlots
  46.         set the loc of sprite (theSlot + baseRecordSprOffset) to point(-1000, 0)
  47.       end repeat
  48.       set the castNum of sprite backgroundSpr to backgroundCastNumber
  49.       if (the mouseV >= theMinV) and (the mouseV <= theMaxV) then
  50.         set the locV of sprite backgroundSpr to the mouseV
  51.       else
  52.         if the mouseV < theMinV then
  53.           set the locV of sprite backgroundSpr to theMinV
  54.         else
  55.           if the mouseV > theMaxV then
  56.             set the locV of sprite backgroundSpr to theMaxV
  57.           end if
  58.         end if
  59.       end if
  60.     else
  61.       showFrame(playbackMgr, currentFrame, 0)
  62.     end if
  63.     updateStage()
  64.   end repeat
  65.   set theMouseLoc to point(the mouseH, the mouseV)
  66.   if inside(theMouseLoc, theStageBounds) then
  67.     set nukeChannels to []
  68.     repeat with theSlot in nukeSlots
  69.       append(nukeChannels, getAt(getAt(dispatchTable, theSlot), 3))
  70.     end repeat
  71.     repeat with theChannel in nukeChannels
  72.       deletePropPart(editMgr, theChannel)
  73.     end repeat
  74.     set theBackgroundSprV to the locV of sprite backgroundSpr
  75.     set currentBgdData to list(backgroundCastNumber, 313, theBackgroundSprV)
  76.     set countBgdData to count(bgdData)
  77.     set firstTimeFlag to 0
  78.     if (countBgdData = 1) and (getAt(bgdData, 1) = [5051, 313, 243]) then
  79.       set firstTimeFlag to 1
  80.       repeat with theFrameNumber = 1 to count(scoreData)
  81.         setAt(bgdData, theFrameNumber, currentBgdData)
  82.       end repeat
  83.     else
  84.       if countBgdData < currentFrame then
  85.         repeat with theFrameNumber = countBgdData + 1 to currentFrame - 1
  86.           setAt(bgdData, theFrameNumber, previousBackgroundCast)
  87.         end repeat
  88.         repeat with theFrameNumber = currentFrame to count(scoreData)
  89.           setAt(bgdData, theFrameNumber, currentBgdData)
  90.         end repeat
  91.       else
  92.         repeat with theFrameNumber = currentFrame to count(scoreData)
  93.           setAt(bgdData, theFrameNumber, currentBgdData)
  94.         end repeat
  95.       end if
  96.     end if
  97.     showFrame(playbackMgr, currentFrame, 0)
  98.     set dirtyFlag to 1
  99.     updateTheBrain(appMgr)
  100.   else
  101.     unLoadCast(backgroundCastNumber)
  102.     showFrame(playbackMgr, currentFrame, 0)
  103.   end if
  104. end
  105.  
  106. on addPropsToBackground me, backgroundName, firstTimeFlag
  107.   set partsList to value(line 1 of field "partsListData")
  108.   set propNameList to getaProp(partsList, value("#" & backgroundName))
  109.   if not voidp(propNameList) then
  110.     repeat with propName in propNameList
  111.       repeat with lineNumber = 1 to the number of lines in field "ppcData"
  112.         if value(item 2 of line lineNumber of field "ppcData") = propName then
  113.           set curClipRecord to value(line lineNumber of field "ppcData")
  114.           exit repeat
  115.         end if
  116.       end repeat
  117.       set layerOverflow to 0
  118.       set theType to getAt(curClipRecord, 1)
  119.       set theGroup to getAt(curClipRecord, 2)
  120.       set theOffsets to getAt(curClipRecord, 3)
  121.       set hOffset to getAt(theOffsets, 1)
  122.       set vOffset to getAt(theOffsets, 2)
  123.       if isEmptyP(layerMgr) then
  124.         set curDataChannel to addNewSlot(layerMgr, theType, theGroup, clipDataField)
  125.       else
  126.         set curDataChannel to findDuplicateCategory(layerMgr, theGroup)
  127.         if curDataChannel = 0 then
  128.           set recordingDuplicateClip to 0
  129.           if isFullP(layerMgr) then
  130.             set layerOverflow to 1
  131.           else
  132.             set curDataChannel to addNewSlot(layerMgr, theType, theGroup, clipDataField)
  133.             if (theType = "S") or (theType = "P") then
  134.               insertProp(layerMgr, theType, theGroup)
  135.             end if
  136.           end if
  137.         end if
  138.       end if
  139.       if not layerOverflow then
  140.         set theLayer to getLayer(layerMgr, theGroup)
  141.         set theRecordingLayer to theLayer + baseRecordSprOffset
  142.         setupClipData(me)
  143.         update(stackMgr)
  144.         set propH to the locH of sprite backgroundSpr + hOffset
  145.         set propV to the locV of sprite backgroundSpr + vOffset
  146.         set frameData to list(firstClip, propH, propV)
  147.         set oldCurrentFrame to currentFrame
  148.         if firstTimeFlag then
  149.           set currentFrame to 1
  150.         end if
  151.         repeat with theFrameNumber = currentFrame to count(scoreData)
  152.           addFrame(listMgr, frameData, curDataChannel)
  153.           incrementFrame()
  154.         end repeat
  155.         set currentFrame to oldCurrentFrame
  156.       end if
  157.     end repeat
  158.   end if
  159. end
  160.